﻿using Nop.Core.Domain.Tax;
using System.Data.Entity.ModelConfiguration;

namespace Nop.Data.Mapping.Tax
{
    public class SurchargeMap : EntityTypeConfiguration<Surcharge>
    {
        public SurchargeMap()
        {
            this.ToTable("Surcharge");
            this.HasKey(s => s.Id);
            this.Property(s => s.Value).HasPrecision(18, 4);
            this.Property(s => s.PercentageOrFee).HasPrecision(18, 4);
            this.Property(s => s.Zip).IsOptional();
            this.Property(s => s.StateProvinceId).IsOptional();
            this.Property(s => s.CountryId).IsOptional();
            this.HasRequired(s => s.SurchargeType)
                .WithMany()
                .HasForeignKey(s => s.SurchargeTypeId)
                .WillCascadeOnDelete(false);
            this.HasRequired(s => s.Order)
                .WithMany()
                .HasForeignKey(s => s.OrderId)
                .WillCascadeOnDelete();
        }
    }
}
